/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

//package server;

import java.util.ArrayList;

/**
 *
 * @author josegarcia
 */
class ExcecThread extends Thread{
    private ArrayList<Request> tasks;
    private Object lockTasks;
    private Boolean listening;

    public ExcecThread(ArrayList<Request> tasks, Object lockTasks,Boolean listening) {
	super();
	this.tasks=tasks;
	this.lockTasks=lockTasks;
	this.listening=listening;
    }
    public void run(){
	Request task;
	while(true){
	    synchronized(this){
	    	while(tasks.size()==0){
		
		    try {
			wait();
		    } catch (InterruptedException e) {}
		}
	    }

	    synchronized(lockTasks){
		task=tasks.remove(0);
	    }
	    task.execute(listening);
	}

    }

}
